home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / TC Prog Guide.cpt / picture ƒ / ringpict.c < prev    next >
C/C++ Source or Header  |  1991-02-27  |  3KB  |  148 lines

  1. /*
  2. *    FILE:        ringpict.c
  3. *    AUTHOR:        R. Gonzalez
  4. *    CREATED:    November 7, 1990
  5. *
  6. *    Sample pict application.  Includes main() function.
  7. *
  8. *    ASSOCIATED FILES:
  9. *        ringpict.h,class.c,class.h,screen.c,screen.h,,coord.c,coord.h,
  10. *        frame.c,frame.h,color.h,error.c,error.h,trans.c,trans.h,oops.h,
  11. *        camera.c,camera.h,project.c,project.h,segment.c,segment.h,
  12. *        line.c,line.h,cube.c,cube.h,ring.c,ring.h,backdrop.c,
  13. *        backdrop.h,pict.c,pict.h, several ANSI and system-specific
  14. *        headers (used in screen.c and class.c).
  15. *
  16. *    PROJECT CONTENTS (Think C):
  17. *        above-listed source (.c) files, MacTraps, ANSI or ANSI-881,
  18. *        oops library.
  19. *
  20. *    COMPILATION (Think C):
  21. *        68881 code generation if ANSI-881 is used.
  22. */
  23.  
  24. # include    "ringpict.h"
  25. # include    "ring.h"
  26.  
  27. /******************************************************************
  28. *    initialize
  29. ******************************************************************/
  30. boolean    Ring_Pict::init(void)
  31. {
  32.     Rotation_X        *rotx;
  33.     Translation        *transl;
  34.     Transformation    *combination;
  35.     
  36.     Generic_Pict::init();
  37.     
  38.     projector1 = new(Projector);
  39.     projector1->init();
  40.     projector1->set_background_color(BLUE);
  41.     projector1->set_cropping_frame(0.,-.05,1.,.5);
  42.     projector1->set_projection_frame(-.2,0.,1.4,.7);
  43.  
  44.     projector2 = new(Corner_Projector);
  45.     projector2->init();
  46.     
  47.     projector3 = new(Projector);
  48.     projector3->init();
  49.     projector3->set_background_color(YELLOW);
  50.     projector3->set_cropping_frame(0.,-.05,1.,.5);
  51.     projector3->set_projection_frame(.8,.15,.3,.8);
  52.     
  53.     projector1->set_screen(screen);
  54.     projector2->set_screen(screen);
  55.     projector3->set_screen(screen);
  56.     
  57.     camera1 = new(Camera);
  58.     camera1->init();
  59.     camera2 = new(Camera);
  60.     camera2->init();
  61.     camera2->set_position(0.,10.,10.,0.,PI/2.,0.);
  62.     
  63.     rotx = new(Rotation_X);
  64.     rotx->init();
  65.     rotx->set(-PI/12.);
  66.     transl = new(Translation);
  67.     transl->init();
  68.     transl->set(0.,0.,10.);
  69.     combination = new(Transformation);
  70.     combination->init();
  71.     combination->combine(rotx,transl);
  72.     
  73.     segment = new(Ring);
  74.     segment->init();
  75.     segment->move(combination);
  76.     
  77.     rotx->destroy();
  78.     delete(rotx);
  79.     transl->destroy();
  80.     delete(transl);
  81.     combination->destroy();
  82.     delete(combination);
  83.     
  84.     return TRUE;
  85. }
  86.  
  87. /******************************************************************
  88. *    run
  89. ******************************************************************/
  90. void    Ring_Pict::run(void)
  91. {
  92.     Transformation    *identity;
  93.     
  94.     identity = new(Transformation);
  95.     identity->init();
  96.     
  97.     segment->set_color(CYAN);
  98.     segment->draw(camera1,projector1,identity);
  99.     segment->set_color(GREEN);
  100.     segment->draw(camera2,projector2,identity);
  101.     segment->set_color(RED);
  102.     segment->draw(camera1,projector3,identity);
  103.  
  104.     screen->wait();
  105.     
  106.     identity->destroy();
  107.     delete(identity);
  108. }
  109.  
  110. /******************************************************************
  111. *    destroy
  112. ******************************************************************/
  113. boolean    Ring_Pict::destroy(void)
  114. {
  115.     projector1->destroy();
  116.     delete(projector1);
  117.     projector2->destroy();
  118.     delete(projector2);
  119.     projector3->destroy();
  120.     delete(projector3);
  121.  
  122.     camera1->destroy();
  123.     delete(camera1);
  124.     camera2->destroy();
  125.     delete(camera2);
  126.     
  127.     segment->destroy();
  128.     delete(segment);
  129.  
  130.     return Generic_Pict::destroy();
  131. }
  132.  
  133. /******************************************************************
  134. *    main function
  135. ******************************************************************/
  136. main()
  137. {
  138.     Generic_Pict    *pict;
  139.     
  140.     pict = new(Ring_Pict);
  141.     pict->init();
  142.     pict->run();
  143.     pict->destroy();
  144.     delete(pict);
  145. }
  146.  
  147.     
  148.